Cryptography Engineering by Niels Ferguson & Bruce Schneier & Tadayoshi Kohno
Author:Niels Ferguson & Bruce Schneier & Tadayoshi Kohno
Language: eng
Format: epub
Publisher: Wiley
Published: 2011-01-27T05:00:00+00:00
10.2 Generating Small Primes
Sometimes it is useful to have a list of small primes, so here is the Sieve of Eratosthenes, which is still the best algorithm for generating small primes. The 220 in the pseudocode below is a stand-in for any appropriate small constant.
function SMALLPRIMELIST
input: n Limit on primes to generate. Must satisfy 2 ≤ n ≤ 220.
output: P List of all primes ≤n.
Limit the size of n. If n is too large we run out of memory.
assert 2 ≤ n ≤ 220
Initialize a list of flags all set to one.
(b2, b3, …, bn) ← (1, 1, …, 1)
i ← 2
while i2 ≤ n do
We have found a prime i. Mark all multiples of i composite.
for j ∈ 2i, 3i, 4i, …, n/i i do
bj ← 0
od
Look for the next prime in our list. It can be shown that this loop never results
in the condition i > n, which would access a nonexistent bi.
repeat
i ← i + 1 bi=1
od
All our primes are now marked with a one. Collect them in a list.
P ← []
for k ∈ 2, 3, 4, …, n do
if bk = 1 then
P ← P || k
fi
od
return P
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Effective Threat Investigation for SOC Analysts by Yahia Mostafa;(6578)
Practical Memory Forensics by Svetlana Ostrovskaya & Oleg Skulkin(6298)
Machine Learning Security Principles by John Paul Mueller(6271)
Attacking and Exploiting Modern Web Applications by Simone Onofri & Donato Onofri(5944)
Operationalizing Threat Intelligence by Kyle Wilhoit & Joseph Opacki(5905)
Solidity Programming Essentials by Ritesh Modi(4042)
Microsoft 365 Security, Compliance, and Identity Administration by Peter Rising(3681)
Operationalizing Threat Intelligence by Joseph Opacki Kyle Wilhoit(3411)
Future Crimes by Marc Goodman(3351)
Mastering Python for Networking and Security by José Manuel Ortega(3348)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3337)
Blockchain Basics by Daniel Drescher(3305)
Learn Computer Forensics - Second Edition by William Oettinger(3172)
Incident Response with Threat Intelligence by Roberto Martínez(2898)
Mobile App Reverse Engineering by Abhinav Mishra(2886)
Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos(2873)
The Code Book by Simon Singh(2832)
From CIA to APT: An Introduction to Cyber Security by Edward G. Amoroso & Matthew E. Amoroso(2783)
Building a Next-Gen SOC with IBM QRadar: Accelerate your security operations and detect cyber threats effectively by Ashish M Kothekar(2760)
